import Mocks from "mockjs";
import moment from "moment";
import { iresponse, paramObj } from "../index";

const getMenber = () => {
    return Mocks.mock({
      ["list|300"]: [
        {
          user_id: "@increment(1)",
          phone: "13@string('number',9)",
          "gender|1-2": 1,
          "status|0-1": 1,
          openid:'233455',
         // username:'@name',
          nick_name:"@cname",
          created_by:'',
          created_time: "@date('yyyy-MM-dd')",
          updated_by:'',
          updated_time: "@date('yyyy-MM-dd')",
          head_img_url:"@image('250X250','#FFA07A','#FFBBFF','png','hh')"
        },
      ],
    });
  };

export const memberList=getMenber().list



const listurl = /\/api\/member\/list(|\?\.*)/;
Mocks.mock(listurl, (config) => {
  const  param= paramObj(config.url);
  const current=param.current?param.current:1
  const pageSize=param.pageSize?param.pageSize:10
  const start = (current - 1) * pageSize;
  const end = current * pageSize;
  const list = memberList.slice(start, end);

  return iresponse({
    list,
    total: 300,
  });
});


const url = /\/api\/member\/info(|\?\.*)/;
Mocks.mock(url, (config) => {
  const params = paramObj(config.url);
  console.log(params);
  const data = memberList.find((v) => v.user_id == params.userId);
  return iresponse(data);
});